import { _decorator, Component, Node, v3 } from 'cc';
import { GlobalEnum } from '../../../Init/Config/GlobalEnum';
import GlobalPool from '../../../Init/Tools/GlobalPool';
import { MappingObj } from './MappingObj';
const { ccclass, property } = _decorator;

@ccclass('MappingBullet')
export class MappingBullet extends MappingObj {
    y = 0;
    init(y): void {
        super.init();
        this.y = y;
        //计算角度
        const v = this.mappingProps.node[GlobalEnum.ExtralProp.curLineVec2d];
        let angY = Math.atan2(v.y, v.x) * 57.3;
        let ang = v3(0, angY, 0);
        this.node.eulerAngles = ang;
    }

    updateProp() {
        //回收
        if (!this.mappingProps.node.active) {
            GlobalPool.put(this.node);
            return;
        }

        //位置
        this.tmpP.set(this.mappingProps.node.position);
        this.tmpP.z = -this.tmpP.y;
        this.tmpP.multiplyScalar(this.s3d);
        this.tmpP.y = this.y;
        this.node.setPosition(this.tmpP);

    }
}

